import { useState, useEffect } from 'react'
import { getAllConfigs } from '~/api/config'

export default function useGetAllConfigs() {
  const [configs, setConfigs] = useState<any>({})
  useEffect(() => {
    if (!localStorage.getItem('u') || (localStorage.getItem('u') && !JSON.parse(localStorage.getItem('u')!).roles))
      return
    getAllConfigs().then((res: any) => {
      setConfigs(res)
    })
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, [localStorage.getItem('u')])
  return configs
}
